home *** CD-ROM | disk | FTP | other *** search
AmigaBASIC Source Code | 1986-03-20 | 7.6 KB | 296 lines | [MSBC/MSBB] |
- 'HANGMAC
- '©MACTUTOR, 1986
- 'by David Kelly
-
- Initialize:
- CLEAR,20000
- DEFINT a-z
- DIM wordchar(1)
- false=0:true=NOT false
- talk=true:number=15
- DIM wordarray$(number)
- ON ERROR GOTO 10
- LIBRARY "SpeechLib"
- 5 :ON ERROR GOTO 0
- IF talk=true THEN GOSUB InitTalk
- FOR i=1 TO number
- READ wordarray$(i)
- NEXT i
- blank$=""
- FOR i=1 TO 40:blank$=blank$+" ":NEXT i
- WINDOW CLOSE 1
- FOR i=1 TO 5
- MENU i,0,0,""
- NEXT i
-
- MENU 1,0,1,"File"
- MENU 1,1,1,"Instructions"
- MENU 1,2,1,"Start Game"
- MENU 1,3,1,"Quit"
- MENU 2,0,1,"Speech"
- MENU 2,1,2,"ON"
- MENU 2,2,1,"OFF"
- IF talk=false THEN MENU 2,0,0
- WrongGuess=10
- GOSUB HangSetup
- GOSUB DrawHangMac
- ON MENU GOSUB menuevent
- MENU ON
- idleloop: GOTO idleloop
-
- menuevent:
- menunumber=MENU(0):IF menunumber=2 THEN Speechmenu
- menuitem=MENU(1):MENU
- MENU 1,0,0
- ON menuitem GOSUB Instructions,Start,Quit
- RETURN
-
- Speechmenu:
- menuitem=MENU(1):MENU
- IF menuitem=1 THEN MENU 2,1,2:MENU 2,2,1:talk=true
- IF menuitem=2 THEN MENU 2,1,1:MENU 2,2,2:talk=false
- MENU ON
- RETURN
-
- InitTalk:
- SpeechHand!=0:SpeechErr%=0:Phon$=""
- hertz%=190:mode%=0:Wpm%=125
- SpeechOn! "",SpeechHand!,SpeechErr%
- SpeechPitch! SpeechHand!,hertz%,mode%
- SpeechRate! SpeechHand!,Wpm%
- POKE &H208,5
- RETURN
-
- Quit:
- GOSUB ClearKeyboard
- IF talk=true THEN Eng$="Good buy. Play again sometime.":GOSUB Speakup
- IF talk=true THEN SpeechOff! SpeechHand! :LIBRARY CLOSE
- WINDOW CLOSE 1
- WINDOW CLOSE 2
- WINDOW CLOSE 3
- MENU RESET
- END
-
- Start:
- MENU ON
- x!=FRE(1)
- RANDOMIZE TIMER
- index=INT(RND(1)*number)
- IF index=0 THEN Start
- word$=wordarray$(index)
- GOSUB HangSetup
- ERASE wordchar
- DIM wordchar(LEN(word$))
- FOR i=1 TO LEN(word$)
- wordchar(i)=false
- NEXT i
- usedchar=0:used$=""
- WrongGuess=0:lose=false
- <0xd320441,0xd318010>(2)
- <0xd32045e,0xd318010>(14)
- <0xd32047c,0xd318010>(1)
- wflag=false
- sumword=0
- GOSUB DisplayWord
- IF talk=false THEN inputchar
- Eng$="Your word is "+STR$(LEN(word$))+" characters long."
- GOSUB Speakup
- inputchar:
- WINDOW 1
- GOSUB DrawHangPost
- GOSUB ClearKeyboard
- EDIT FIELD 1,"",(95,190)-(410,210),1,2
- IF talk=false THEN charloop
- Eng$="Please choose a letter"
- GOSUB Speakup
- charloop:
- d=<0x43,0xd318010>(0)
- IF d<>6 THEN charloop
- char$=UCASE$(EDIT$(1))
- IF char$="" THEN inputchar
- IF talk=false THEN checkchar
- Eng$="You have selected, "+char$+". "
- IF char$<"A" OR char$>"Z" THEN Eng$=Eng$+"That character is not a loud."
- IF INSTR(used$,char$)<>0 THEN Eng$=Eng$+"That letter is already used."
- Wrong:IF char$<>word$ AND LEN(char$)<>1 THEN Eng$=Eng$+"WRONGE!"
- GOSUB Speakup
- checkchar:
- IF char$<"A" OR char$ >"Z" THEN inputchar
- IF INSTR(used$,char$)<>0 THEN inputchar
- IF char$=word$ THEN GOSUB foundword
- IF char$<>word$ AND LEN(char$)<>1 THEN WrongGuess=WrongGuess+1:GOSUB DrawHangMac :GOTO inputchar
- used$=used$+char$+" "
- oldsum=sumword
- sumword=0
- FOR i=1 TO LEN(word$)
- IF char$=MID$(word$,i,1) THEN wordchar(i)=true
- sumword=wordchar(i)+sumword
- NEXT i
- Eng$="That's "
- IF oldsum=sumword THEN WrongGuess=WrongGuess+1:Eng$=Eng$+"WRONG!"
- IF sumword=-LEN(word$) THEN wflag=true
- IF (wflag=false) AND (oldsum<>sumword) THEN Eng$=Eng$+"Right. There is at least one "+char$+" in the word."
- IF wflag=true THEN Eng$=Eng$+"Right. You have guessed the word."
- IF talk=true THEN GOSUB Speakup
- GOSUB DisplayUsedChars
- GOSUB DrawHangMac
- GOSUB DisplayWord
- IF wflag=false AND lose=false THEN inputchar
- IF wflag=true THEN Eng$="You Won. The word is "+word$+". Select Start Game to Play again."
- IF lose=true THEN Eng$="You're dead. The word is "+word$+". Select Start Game to Play again."
- IF talk=true THEN GOSUB Speakup
- FOR i=1 TO LEN(word$)
- wordchar(i)=true
- NEXT i
- WINDOW 1
- EDIT FIELD CLOSE 1
- MENU 1,0,1
- RETURN
-
- HangSetup:
- WINDOW 1,"HangMac",(10,100)-(500,320),2
- <0xd31fcd5,0xd318010>(2):<0x14,0x07>(18):<0x14,0x02>(1)
- LOCATE 1,1:PRINT "HangMac"
- <0xd31fd30,0xd318010>(10):<0x0e,0x02>(0)
- PRINT " Copyright ©MacTutor, 1986"
- PRINT" by David Kelly."
- WINDOW 2,"",(95,30)-(410,45),2
- WINDOW 3,"",(95,65)-(410,80),2
- WINDOW 1
- RETURN
-
- foundword:
- wflag=true
- FOR i=1 TO LEN(word$)
- wordchar(i)=true
- NEXT i
- RETURN
-
- DisplayWord:
- WINDOW 3
- LOCATE 1,1
- PRINT blank$:LOCATE 1,1
- IF lose=true THEN PRINT word$;:RETURN
- FOR j=1 TO LEN(word$)
- IF wordchar(j)=true THEN PRINT MID$(word$,j,1); :ELSE PRINT "_ ";
- NEXT j
- RETURN
-
- DisplayUsedChars:
- IF LEN(char$)>1 THEN RETURN
- WINDOW 2
- LOCATE 1,1
- PRINT used$;
- RETURN
-
- DrawHangMac:
- WINDOW 1
- GOSUB DrawHangPost
- IF WrongGuess >=1 THEN CIRCLE(250,35),25
- IF WrongGuess >=2 THEN CIRCLE(260,25),5
- IF WrongGuess >=3 THEN CIRCLE(240,25),5
- IF WrongGuess >=4 THEN LINE(240,45)-(260,45)
- CALL <0x0b,0xd318010>(2,2)
- CALL <0x0d,0xd318010>(250,60)
- IF WrongGuess >=5 THEN CALL <0x19,0xd318010>(250,125)
- IF WrongGuess >=6 THEN CALL LINE(45,45)
- IF WrongGuess >=7 THEN CALL <0x25,0xd318010>(250,125):CALL LINE(-45,45)
- IF WrongGuess >=8 THEN CALL <0x25,0xd318010>(250,90):CALL LINE(25,-25)
- IF WrongGuess >=9 THEN CALL <0x26,0xd318010>(250,90):CALL LINE(-25,-25)
- CALL <0x06,0xd318010>
- IF WrongGuess >=9 THEN CALL <0x3c,0xd318010>(255,20):CALL LINE(10,10):CALL <0x3c,0x02>(255,30):CALL LINE(10,-10)
- IF WrongGuess >=9 THEN CALL <0x3c,0xd318010>(235,20):CALL LINE(10,10):CALL <0x3c,0x02>(235,30):CALL LINE(10,-10)
- IF WrongGuess >=9 THEN lose=true
- RETURN
-
- DrawHangPost:
- CALL <0x0b,0xd318010>(4,4)
- CALL <0x0c,0xd318010>(250,5)
- CALL <0x0d,0xd318010>(310,5)
- CALL <0x0e,0xd318010>(310,185)
- RETURN
-
- ClearKeyboard:
- key$="X"
- WHILE key$ <>""
- key$=INKEY$
- WEND
- RETURN
-
- 10 :IF ERR=53 THEN talk=false
- RESUME 5
- END
-
- Instructions:
- WINDOW CLOSE 2
- WINDOW CLOSE 3
- WINDOW 1,"Instructions",(10,30)-(500,330),-2
- <0xd320502,0xd318010>(2):<0x14,0x07>(18):<0x14,0x02>(1)
- LOCATE 1,15:PRINT "HangMac"
- <0xd32055e,0xd318010>(12):<0x0e,0x02>(0)
- LOCATE 3,1:PRINT "HangMac is the audio version of the traditional game of";
- PRINT" Hangman. To play":PRINT"the game just choose ";
- <0xd320617,0xd318010>(0):PRINT"Start Game";:<0x1c,0x07>(2)
- PRINT" from the File menu. The hanging post is"
- PRINT "drawn and you may start guessing letters by typing them onto the base of"
- PRINT"the hanging post. The uppermost window will display the characters which"
- PRINT"you have used. The next window shows the characters, or blanks for the"
- PRINT"word that you are guessing. Each time you miss, a new part of the HangMac"
- PRINT"man will be drawn until the entire body is drawn. If you guess wrong ten"
- PRINT"times then you lose. Type the whole word to guess the word."
- PRINT"This program features CLR SpeechLib procedures for calling Macintalk."
- PRINT"To use the speech feature you must have CLR SpeechLib (available from"
- PRINT"Clear Lake Research, 5353 Dora Street, Suite 7, Houston, Texas 77005"
- PRINT"(800-835-2246 X 199). However, the program will still work without"
- PRINT"the speech libraries being available."
- PRINT:PRINT"HangMac, Copyright ©MacTutor, 1986, by David Kelly."
- <0x40,0xd318010> 1,1,"OK",(445,260)-(475,290)
- IF talk=true THEN <0x40,0xd318010> 2,1,"TALK",(365,260)-(425,290)
- WaitforButton:
- WHILE <0x43,0xd318010>(0)<>1:WEND
- buttonpushed = <0x43,0xd318010>(1)
- IF buttonpushed=2 THEN GOSUB SpeakInstructions:GOTO WaitforButton
- <0x40,0xd318010> CLOSE 1
- <0x40,0xd318010> CLOSE 2
- WINDOW CLOSE 1
- MENU 1,0,1
- RETURN
-
- SpeakInstructions:
- <0x40,0xd318010> 1,0:<0x40,0x07> 2,0
- Eng$=" HangMac is the audio version of the traditional game of Hangman. To play"
- Eng$=Eng$+" the game just choose Start Game from the File menu. The hanging post is"
- Eng$=Eng$+" drawn and you may start guessing letters by typing them onto the base of"
- Eng$=Eng$+" the hanging post. The uppermost wyndoe will display the charactors which"
- Eng$=Eng$+" you have used. The next wyndoe shows the characters, or blanks for the"
- Eng$=Eng$+" word that you are guessing. Each time you miss, a new part of the HangMac"
- Eng$=Eng$+"-man will be drawn until the entire body is drawn. If you guess wrong ten"
- Eng$=Eng$+" times then you luse. Type the whole word to guess the word."
- ReaderString! SpeechHand!,Eng$,Phon$,SpeechErr%
- SoundOutString! SpeechHand!,Phon$,SpeechErr%
- Eng$="This program features CLR SpeechLib proseedures for calling Macintalk."
- Eng$=Eng$+" To use the speech feature you must have CLR SpeechLib (available from"
- Eng$=Eng$+" Clear Lake Reserch, 5353 Dora Street, sweet 7, Huse ton, Texas 77005."
- Eng$=Eng$+" phone- eight hundred 835-2246 extension199. However, the program will still work without the speech lybraries"
- Eng$=Eng$+" being available."
- Eng$=Eng$+" HangMac, Copy right MacTutor, nineteen eighty six, by Dayvid Kelly."
- ReaderString! SpeechHand!,Eng$,Phon$,SpeechErr%
- SoundOutString! SpeechHand!,Phon$,SpeechErr%
- Eng$="":Phon$=""
- <0x40,0xd318010> 1,1:<0x40,0x07> 2,1
- RETURN
- Speakup:
- ReaderString! SpeechHand!, Eng$,Phon$,SpeechErr%
- SoundOutString! SpeechHand!,Phon$,SpeechErr%
- RETURN
-
- 'Add additional words (as you please)
- 'by adding to the DATA statements below
- 'change the variable 'number' at the beginning
- 'of the program to reflect the number of words
- 'available.
-
- DATA "MACINTOSH","MOUSE","DISK","DESKTOP","CURSOR"
- DATA "ICON","KEYBOARD","WINDOW","MENU","PRINTER"
- DATA "MODEM","BYTE","MEMORY","PROGRAM","DATA"
-